package com.android.meige.utils;

import android.content.Context;
import android.content.Intent;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentManager;
import android.text.TextUtils;
import android.view.View;

import com.android.meige.MainActivity;
import com.android.meige.R;
import com.android.meige.activity.BargainWeb;
import com.android.meige.activity.BaseObject;
import com.android.meige.activity.BaseWeb;
import com.android.meige.activity.GoodsDetailActivity;
import com.android.meige.activity.GoodsStoreActivity;
import com.android.meige.activity.MainRecommendType;
import com.android.meige.activity.MainTab;
import com.android.meige.activity.mine.LoginActivity;
import com.android.meige.enums.EJumpStatus;
import com.android.meige.fragment.Fragment1;
import com.android.meige.fragment.group.Fragment_BrandClearance;
import com.android.meige.fragment.group.Fragment_BrandDiscountMain;
import com.android.meige.fragment.group.Fragment_CFundingTaste;
import com.android.meige.fragment.group.Fragment_ColonelFree;
import com.android.meige.fragment.group.Fragment_EveryBodyBuy;
import com.android.meige.fragment.group.Fragment_FreePostage;
import com.android.meige.fragment.group.Fragment_NearbyStore;
import com.android.meige.fragment.group.Fragment_StoreStreet;
import com.android.meige.fragment.member.Fragment_SameCity_Service;
import com.android.meige.pojo.BannerRegmatchPojo;
import com.android.meige.pojo.BannerUintPojo;
import com.android.meige.view.group.BannerItemFragment;

import java.util.regex.Matcher;
import java.util.regex.Pattern;

/**
 * Created by Administrator on 2017/11/8.
 */

public class JumpUtils {

    /**
     * EnumSeckill("Seckill","秒杀团","Seckill"),
     * EnumFreeTest("FreeTest","免费试用","FreeTest"),
     * EnumBrandDiscount("BrandDiscount","品牌折扣","BrandDiscount"),  -- Fragment_Group and BaseObject
     * EnumSpread("Spread","高佣推广","Spread"),
     * EnumFreePostage("FreePostage","9.9元包邮","FreePostage"),
     * EnumHotSail("HotSail","热销榜","HotSail"),
     * EnumNeighbor("Neighbor","邻居团","Neighbor"),
     * EnumPromote("Promote","推广团","Promote"),
     * EnumNewHotSail("NewHotSail","新品热销","NewHotSail"),
     * EnumSameCity("SameCity","同城新零售","SameCity"),
     * EnumStair("Stair","专题","Stair:id"),
     * EnumStore("Store","店铺","Store:id"),
     * EnumDetail("Detail","详情","Detail:id"),
     * EnumGoodsList("GoodsList","产品列表","GoodsList:id");
     * <p>
     * GetApp().jumpToEveryWhere(getActivity(), Apojo, Fragment1.this);
     * <p>
     * GetApp().jumpToEveryWhere(MainActivity.this, Apojo, null);
     *
     * @param Apojo Fragment 这个是Fragment才会有的。 而继承于ommonActivity的把它设为null
     *              <p>
     *              有处理，就返回ture;没处理就返回false
     *              <p>
     *              <p>
     *              <p>
     *              <p>
     *              <p>
     *              <p>
     *              <p>
     *              //Fragment_Group：首页装载的Fragment
     */
    public static boolean jumpToEveryWhere(Context mcontext, BannerUintPojo Apojo, Fragment fragment) {
        ReleaseManager.printLog("jumpToEveryWhere", Apojo.toString() + Apojo.return_type);

        if (Apojo.return_type == null || "".equals(Apojo.return_type)) {
            ReleaseManager.printLog("jumpToEveryWhere", "return_type是空的，jumpToEveryWhere不处理！！！！！！");
            return false;
        }

        if (IsRegmatch(Apojo.return_type, EJumpStatus.EnumSeckill.getRegmatch())) {
            ReleaseManager.printLog(EJumpStatus.EnumSeckill.getDescription());
            if (TextUtils.isEmpty(Apojo.title)) {
                Apojo.title = EJumpStatus.EnumSeckill.getDescription();
            }
            toMainTab(mcontext, Apojo, 0, 9);
            return true;
        } else if (IsRegmatch(Apojo.return_type, EJumpStatus.EnumFreeTest.getRegmatch())) {
            ReleaseManager.printLog(EJumpStatus.EnumFreeTest.getDescription());
            if (TextUtils.isEmpty(Apojo.title)) {
                Apojo.title = EJumpStatus.EnumFreeTest.getDescription();
            }
            toMainRecommendType(mcontext, Apojo, "2");
            return true;
        } else if (IsRegmatch(Apojo.return_type, EJumpStatus.EnumNew.getRegmatch())) {
            ReleaseManager.printLog(EJumpStatus.EnumNew.getDescription());
            if (TextUtils.isEmpty(Apojo.title)) {
                Apojo.title = EJumpStatus.EnumNew.getDescription();
            }
            toMainRecommendType(mcontext, Apojo, "0");
            return true;
        } else if (IsRegmatch(Apojo.return_type, EJumpStatus.ELottery.getRegmatch())) {
            ReleaseManager.printLog(EJumpStatus.ELottery.getDescription());
            if (TextUtils.isEmpty(Apojo.title)) {
                Apojo.title = EJumpStatus.ELottery.getDescription();
            }
            toMainRecommendType(mcontext, Apojo, "5");
            return true;
        } else if (IsRegmatch(Apojo.return_type, EJumpStatus.EnumSelf.getRegmatch())) {
            ReleaseManager.printLog(EJumpStatus.EnumSelf.getDescription());
            if (TextUtils.isEmpty(Apojo.title)) {
                Apojo.title = EJumpStatus.EnumSelf.getDescription();
            }
            toMainRecommendType(mcontext, Apojo, "0");
            return true;
        } else if (IsRegmatch(Apojo.return_type, EJumpStatus.EnumLadder.getRegmatch())) {
            if (TextUtils.isEmpty(Apojo.title)) {
                Apojo.title = EJumpStatus.EnumLadder.getDescription();
            }
            toMainRecommendType(mcontext, Apojo, "0");
            return true;
        } else if (IsRegmatch(Apojo.return_type, EJumpStatus.EnumBrandDiscount.getRegmatch())) {
            ReleaseManager.printLog(EJumpStatus.EnumBrandDiscount.getDescription());
            if(mcontext != null){
                if(mcontext instanceof BaseObject){
                    BaseObject baseObject = (BaseObject) mcontext;
                    FragmentManager fm = baseObject.getSupportFragmentManager();
                    fm.beginTransaction().replace(R.id.frament, Fragment_BrandDiscountMain.newInstance()).commit();
                    return true;
                }else {
                    if (TextUtils.isEmpty(Apojo.title)) {
                        Apojo.title = EJumpStatus.EnumBrandDiscount.getDescription();
                    }
                    toObject(mcontext, Apojo);
                    return true;
                }
            }
//            if (fragment != null && fragment instanceof Fragment) {
//                if (TextUtils.isEmpty(Apojo.title)) {
//                    Apojo.title = EJumpStatus.EnumBrandDiscount.getDescription();
//                }
//                toObject(mcontext, Apojo);
//                return true;
//            } else if (mcontext != null && mcontext instanceof BaseObject) {
//                BaseObject baseObject = (BaseObject) mcontext;
//                FragmentManager fm = baseObject.getSupportFragmentManager();
//                fm.beginTransaction().replace(R.id.frament, Fragment_BrandDiscountMain.newInstance()).commit();
//                return true;
//            }

        } else if (IsRegmatch(Apojo.return_type, EJumpStatus.EnumSpread.getRegmatch())) {
            ReleaseManager.printLog(EJumpStatus.EnumSpread.getDescription());
            if (TextUtils.isEmpty(Apojo.title)) {
                Apojo.title = EJumpStatus.EnumSpread.getDescription();
            }
            toMainTab(mcontext, Apojo, 0, 8);
            return true;

        } else if (IsRegmatch(Apojo.return_type, EJumpStatus.EnumFreePostage.getRegmatch())) {
            ReleaseManager.printLog(EJumpStatus.EnumFreePostage.getDescription());
            if(mcontext != null){
                if(mcontext instanceof BaseObject){
                    BaseObject baseObject = (BaseObject) mcontext;
                    FragmentManager fm = baseObject.getSupportFragmentManager();
                    fm.beginTransaction().replace(R.id.frament, Fragment_FreePostage.newInstance()).commit();
                    return true;
                }else {
                    if (TextUtils.isEmpty(Apojo.title)) {
                        Apojo.title = EJumpStatus.EnumFreePostage.getDescription();
                    }
                    toObject(mcontext, Apojo);
                    return true;
                }
            }
        } else if (IsRegmatch(Apojo.return_type, EJumpStatus.EnumHotSail.getRegmatch())) {
            ReleaseManager.printLog(EJumpStatus.EnumHotSail.getDescription());
            if(mcontext != null){
                if(mcontext instanceof BaseObject){
                    BaseObject baseObject = (BaseObject) mcontext;
                    FragmentManager fm = baseObject.getSupportFragmentManager();
                    fm.beginTransaction().replace(R.id.frament, Fragment_EveryBodyBuy.newInstance()).commit();
                    return true;
                }else {
                    if (TextUtils.isEmpty(Apojo.title)) {
                        Apojo.title = EJumpStatus.EnumHotSail.getDescription();
                    }
                    toObject(mcontext, Apojo);
                    return true;
                }
            }
        } else if (IsRegmatch(Apojo.return_type, EJumpStatus.EnumNeighbor.getRegmatch())) {
            ReleaseManager.printLog(EJumpStatus.EnumNeighbor.getDescription());
            if (TextUtils.isEmpty(Apojo.title)) {
                Apojo.title = EJumpStatus.EnumNeighbor.getDescription();
            }
            toMainRecommendType(mcontext, Apojo, "6");
            return true;
        } else if (IsRegmatch(Apojo.return_type, EJumpStatus.EnumPromote.getRegmatch())) {
            ReleaseManager.printLog(EJumpStatus.EnumPromote.getDescription());
            if (TextUtils.isEmpty(Apojo.title)) {
                Apojo.title = EJumpStatus.EnumPromote.getDescription();
            }
            toMainRecommendType(mcontext, Apojo, "0");
            return true;
        } else if (IsRegmatch(Apojo.return_type, EJumpStatus.EnumNewHotSail.getRegmatch())) {
            ReleaseManager.printLog(EJumpStatus.EnumNewHotSail.getDescription());
            if (mcontext != null && mcontext instanceof MainActivity) {
                MainActivity A1 = (MainActivity) mcontext;
                A1.ChangeMainFragment(1);
                return true;
            }

        } else if (IsRegmatch(Apojo.return_type, EJumpStatus.EnumSea.getRegmatch())) {
            ReleaseManager.printLog(EJumpStatus.EnumSea.getDescription());
            if (mcontext != null && mcontext instanceof MainActivity) {
                MainActivity A1 = (MainActivity) mcontext;
                A1.ChangeMainFragment(2);
                return true;
            }
        } else if (IsRegmatch(Apojo.return_type, EJumpStatus.EnumSameCity.getRegmatch())) {
            ReleaseManager.printLog(EJumpStatus.EnumSameCity.getDescription());
            if(mcontext != null ){
                if (mcontext instanceof MainActivity) {
                    if (TextUtils.isEmpty(Apojo.title)) {
                        Apojo.title = EJumpStatus.EnumSameCity.getDescription();
                    }
                    MainActivity mainActivity = (MainActivity) mcontext;
                    mainActivity.JumptoSameCity(Apojo.return_type,Apojo.title);
                    return true;
                } else if (mcontext instanceof BaseObject) {
                    BaseObject baseObject = (BaseObject) mcontext;
                    FragmentManager fm = baseObject.getSupportFragmentManager();
                    baseObject.main_top_citychoose.setVisibility(View.VISIBLE);
                    String returncity = LoginState.getInstance().getUserInfo(mcontext, 3);
                    if (!TextUtils.isEmpty(returncity)) {
                        baseObject.main_top_citychoose.setText(returncity);
                        baseObject.main_top_title.setVisibility(View.GONE);
                    }
                    fm.beginTransaction().replace(R.id.frament, Fragment_SameCity_Service.newInstance()).commit();
                    return true;
                }
            }
        } else if (IsRegmatch(Apojo.return_type, EJumpStatus.EnumStair.getRegmatch())) {
            ReleaseManager.printLog(EJumpStatus.EnumStair.getDescription());
            if(mcontext != null){
                if(mcontext instanceof BaseObject){
                    BaseObject baseObject = (BaseObject) mcontext;
                    baseObject.jumptoStair();
                    return true;
                }else {
                    BannerRegmatchPojo pojo = regMatchOne(Apojo.return_type, EJumpStatus.EnumStair.getRegmatch());
                    if (TextUtils.isEmpty(Apojo.title)) {
                        Apojo.title = EJumpStatus.EnumStair.getDescription();
                    }
                    Intent intent_bd = new Intent(mcontext, BaseObject.class);
                    intent_bd.putExtra(ConstantsUrl.INTENT_KEY.MAIN_GROUP_OBJEXT_SORT_TITLE, Apojo.title);
                    intent_bd.putExtra("topicname", Apojo.title);
                    intent_bd.putExtra(ConstantsUrl.INTENT_KEY.MAIN_GROUP_OBJEXT_SORT_NEED_ID, pojo.X1 + "");
                    intent_bd.putExtra(ConstantsUrl.INTENT_KEY.RETURN_TYPE, Apojo.return_type);
                    mcontext.startActivity(intent_bd);
                    return true;
                }
            }
        } else if (IsRegmatch(Apojo.return_type, EJumpStatus.EnumStore.getRegmatch())) {
            ReleaseManager.printLog(EJumpStatus.EnumStore.getDescription());
            if (mcontext != null) {
                if (TextUtils.isEmpty(Apojo.title)) {
                    Apojo.title = EJumpStatus.EnumStore.getDescription();
                }
                BannerRegmatchPojo pojo = regMatchOne(Apojo.return_type, EJumpStatus.EnumStore.getRegmatch());
                Intent intent = new Intent(mcontext, GoodsStoreActivity.class);
                intent.putExtra(ConstantsUrl.INTENT_KEY.MAIN_GROUP_TO_STORE_ID, pojo.X1 + "");
                mcontext.startActivity(intent);
                return true;
            }

        } else if (IsRegmatch(Apojo.return_type, EJumpStatus.EnumDetail.getRegmatch())) {
            BannerRegmatchPojo pojo = regMatchOne(Apojo.return_type, EJumpStatus.EnumDetail.getRegmatch());
            ReleaseManager.printLog(EJumpStatus.EnumDetail.getDescription());
            Intent intent = new Intent(mcontext, GoodsDetailActivity.class);
            intent.putExtra(ConstantsUrl.INTENT_KEY.MAIN_GROUP_TO_DETAIL_ID, pojo.X1 + "");
            mcontext.startActivity(intent);
            return true;

        } else if (IsRegmatch(Apojo.return_type, EJumpStatus.EGoodsList.getRegmatch())) {
            // 首页的上部的切换 ---Fragment_SAMain_TabList里好像也有
            ReleaseManager.printLog(EJumpStatus.EGoodsList.getDescription());
            if (fragment != null && fragment instanceof BannerItemFragment) {
                BannerRegmatchPojo pojo = regMatchOne(Apojo.return_type, EJumpStatus.EGoodsList.getRegmatch());
                // Fragment_Group fragment_Group = (Fragment_Group)fragment; //bug可能是Fragment_SAMain_TabList里好像也有
                //设置id为几的viewpager的切换；在fragment_Group里写
                Fragment1 instent = Fragment1.getInstent();
                instent.setViewPager(pojo.X1+"");
                return true;
            }
        } else if (IsRegmatch(Apojo.return_type, EJumpStatus.EnumShopStreet.getRegmatch())) {
            ReleaseManager.printLog(EJumpStatus.EnumShopStreet.getDescription());
            if(mcontext != null){
                if(mcontext instanceof BaseObject){
                    BaseObject baseObject = (BaseObject) mcontext;
                    FragmentManager fm = baseObject.getSupportFragmentManager();
                    fm.beginTransaction().replace(R.id.frament, Fragment_StoreStreet.newInstance()).commit();
                    return true;
                }else {
                    if (TextUtils.isEmpty(Apojo.title)) {
                        Apojo.title = EJumpStatus.EnumShopStreet.getDescription();
                    }
                    toObject(mcontext, Apojo);
                    return true;
                }
            }
        }else if (IsRegmatch(Apojo.return_type, EJumpStatus.EnumFreeOpen.getRegmatch())) {
            ReleaseManager.printLog(EJumpStatus.EnumFreeOpen.getDescription());
            if(mcontext != null){
                if(mcontext instanceof BaseObject){
                    BaseObject baseObject = (BaseObject) mcontext;
                    FragmentManager fm = baseObject.getSupportFragmentManager();
                    fm.beginTransaction().replace(R.id.frament, Fragment_ColonelFree.newInstance(Apojo.id)).commit();
                    return true;
                }else {
                    if (TextUtils.isEmpty(Apojo.title)) {
                        Apojo.title = EJumpStatus.EnumFreeOpen.getDescription();
                    }
                    toObject(mcontext, Apojo);
                    return true;
                }
            }
        }else if (IsRegmatch(Apojo.return_type, EJumpStatus.EnumCrowdFunding.getRegmatch())) {
            ReleaseManager.printLog(EJumpStatus.EnumCrowdFunding.getDescription());
            if(mcontext != null){
                if(mcontext instanceof BaseObject){
                    BaseObject baseObject = (BaseObject) mcontext;
                    FragmentManager fm = baseObject.getSupportFragmentManager();
                    fm.beginTransaction().replace(R.id.frament, Fragment_CFundingTaste.newInstance(Apojo.id)).commit();
                    return true;
                }else {
                    if (TextUtils.isEmpty(Apojo.title)) {
                        Apojo.title = EJumpStatus.EnumCrowdFunding.getDescription();
                    }
                    toObject(mcontext, Apojo);
                    return true;
                }
            }
        }else if (IsRegmatch(Apojo.return_type, EJumpStatus.EnumBrandClearance.getRegmatch())) {
            ReleaseManager.printLog(EJumpStatus.EnumBrandClearance.getDescription());
            if(mcontext != null){
                if(mcontext instanceof BaseObject){
                    BaseObject baseObject = (BaseObject) mcontext;
                    FragmentManager fm = baseObject.getSupportFragmentManager();
                    fm.beginTransaction().replace(R.id.frament, Fragment_BrandClearance.newInstance(Apojo.id)).commit();
                    return true;
                }else {
                    if (TextUtils.isEmpty(Apojo.title)) {
                        Apojo.title = EJumpStatus.EnumBrandClearance.getDescription();
                    }
                    toObject(mcontext, Apojo);
                    return true;
                }
            }
        }else if (IsRegmatch(Apojo.return_type, EJumpStatus.EnumWebView.getRegmatch())) {
            if(mcontext != null){
                ReleaseManager.printLog(EJumpStatus.EnumWebView.getDescription());
                Intent intent = new Intent(mcontext, BaseWeb.class);
                intent.putExtra(ConstantsUrl.INTENT_KEY.MAIN_GROUP_MEMBER_WEB_URL, Apojo.return_type);
                mcontext.startActivity(intent);
                return true;
            }
        }else if (IsRegmatch(Apojo.return_type, EJumpStatus.EnumBargain.getRegmatch())) {
            if(mcontext != null) {
                if (LoginState.getInstance().isLogin(mcontext)) {
                    mcontext.startActivity(new Intent(mcontext, BargainWeb.class));
                } else {
                    mcontext.startActivity(new Intent(mcontext, LoginActivity.class));
                }
                return true;
            }
        } else if (IsRegmatch(Apojo.return_type, EJumpStatus.ENearbyStore.getRegmatch())) {
            ReleaseManager.printLog(EJumpStatus.ENearbyStore.getDescription());
            if(mcontext != null ){
                if (mcontext instanceof MainActivity) {
                    if (TextUtils.isEmpty(Apojo.title)) {
                        Apojo.title = EJumpStatus.ENearbyStore.getDescription();
                    }
                    MainActivity mainActivity = (MainActivity) mcontext;
                    mainActivity.JumptoNearbyStore(Apojo.return_type,Apojo.title);
                    return true;
                } else if (mcontext instanceof BaseObject) {
                    BaseObject baseObject = (BaseObject) mcontext;
                    FragmentManager fm = baseObject.getSupportFragmentManager();
                    fm.beginTransaction().replace(R.id.frament, Fragment_NearbyStore.newInstance()).commit();
                    return true;
                }
            }
        }


        //本地的判断
        else if (IsRegmatch(Apojo.return_type, EJumpStatus.ECountry.getRegmatch())) {
            ReleaseManager.printLog(EJumpStatus.ECountry.getDescription());
            if(mcontext != null){
                if(mcontext instanceof BaseObject){
                    BaseObject baseObject = (BaseObject) mcontext;
                    baseObject.JumptoCoutry();
                    return true;
                }else {
                    Intent intent_country = new Intent(mcontext, BaseObject.class);
                    intent_country.putExtra(ConstantsUrl.INTENT_KEY.MAIN_GROUP_OBJEXT_SORT_TITLE, "国家馆");
                    intent_country.putExtra(ConstantsUrl.INTENT_KEY.MAIN_GROUP_OBJEXT_SORT_NEED_ID, Apojo.id);
                    intent_country.putExtra("country_name", Apojo.title);
                    mcontext.startActivity(intent_country);
                    return true;
                }
            }

        }

       /* if(EJumpStatus.WEB_PAGE.getCode().equals(Apojo.RETURN_TYPE)){
            if(Fragment!=null){
                Fragment.jumpToCommonWeb(Apojo.title, Apojo.return_config);
            }else if(context instanceof CommonActivity){
                CommonActivity common = (CommonActivity)context;
                common.jumpToCommonWeb(Apojo.title, Apojo.return_config);
            }else if(context instanceof FragmentBottomTabPager){
                FragmentBottomTabPager common = (FragmentBottomTabPager)context;
                common.jumpToCommonWeb(Apojo.title, Apojo.return_config);
            }else{
                jumpToCommonWeb(Apojo.title, Apojo.return_config);
            }

        }
        else  if(EJumpStatus.Special_recommendation.getCode().equals(Apojo.RETURN_TYPE)){

            CategoryVoucherUintPojo pojo = new CategoryVoucherUintPojo();
            pojo.id=Apojo.return_config;
            pojo.name=Apojo.title;
            Intent intent = new Intent(context, CategorysGoodsActivity.class);
            Bundle bundle = new Bundle();
            bundle.putSerializable("category", pojo);
            intent.putExtras(bundle);
            intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
            context.startActivity(intent);


        }*/
        ReleaseManager.printLog("jumpToEveryWhere", "jumpUtils里没有处理！！！！！！");
        return false;
    }

    private static void toObject(Context mcontext, BannerUintPojo Apojo) {
        Intent intent_bd = new Intent(mcontext, BaseObject.class);
        intent_bd.putExtra(ConstantsUrl.INTENT_KEY.MAIN_GROUP_OBJEXT_SORT_TITLE, Apojo.title);
        intent_bd.putExtra(ConstantsUrl.INTENT_KEY.RETURN_TYPE, Apojo.return_type);
        intent_bd.putExtra(ConstantsUrl.INTENT_KEY.MAIN_GROUP_OBJEXT_SORT_NEED_ID, Apojo.id);
        mcontext.startActivity(intent_bd);
    }

    private static void toMainTab(Context mcontext, BannerUintPojo Apojo, int currentItem, int type) {
        Intent intent_tab = new Intent(mcontext, MainTab.class);
        intent_tab.putExtra(ConstantsUrl.INTENT_KEY.MAIN_GROUP_OBJEXT_SORT_TITLE, Apojo.title);
        intent_tab.putExtra(ConstantsUrl.INTENT_KEY.MAIN_GROUP_TAB_SORT_SHOW_ID, currentItem);
        intent_tab.putExtra(ConstantsUrl.INTENT_KEY.MAIN_GROUP_TAB_SORT_SHOW_TYPE, type);
        intent_tab.putExtra(ConstantsUrl.INTENT_KEY.MAIN_GROUP_OBJEXT_SORT_RATE_ID, Apojo.id);
        mcontext.startActivity(intent_tab);
    }

    private static void toMainRecommendType(Context mcontext, BannerUintPojo Apojo, String type) {
        Intent intent = new Intent(mcontext, MainRecommendType.class);
        intent.putExtra(ConstantsUrl.INTENT_KEY.MAIN_GROUP_SORT_SHOW_TITLE, Apojo.title);
        intent.putExtra(ConstantsUrl.INTENT_KEY.RETURN_TYPE, Apojo.return_type);
        intent.putExtra(ConstantsUrl.INTENT_KEY.MAIN_GROUP_SORT_SHOW_LINK, type);
        mcontext.startActivity(intent);
    }


    public static BannerRegmatchPojo regMatchOne(String withinText, String regString) {
        return regMatch(withinText, regString, 1);
    }

    /**
     * true表示匹配
     * false表示不匹配
     *
     * @param withinText
     * @param regString
     * @return
     */
    public static boolean IsRegmatch(String withinText, String regString) {
        Pattern pattern = Pattern.compile(regString);
        Matcher matcher = pattern.matcher(withinText);
        if (matcher.find()) {
            ReleaseManager.printLog("匹配类型  " + withinText);
            return true;
        }
        return false;

    }

    /**
     * @param withinText  被匹配的正则
     * @param regString   正则表达式
     * @param matchNumber 要匹配的个数
     * @return
     */
    public static BannerRegmatchPojo regMatch(String withinText, String regString, int matchNumber) {
        BannerRegmatchPojo pojo = null;
        Pattern pattern = Pattern.compile(regString);
        Matcher matcher = pattern.matcher(withinText);
        if (matcher.find()) {

            pojo = new BannerRegmatchPojo();

            matcher.reset();
            while (matcher.find()) {
                switch (matchNumber) {
                    case 1:
                        pojo.X0 = matcher.group(0);
                        ReleaseManager.printLog("0匹配  " + pojo.X0);
                        pojo.X1 = matcher.group(1);
                        ReleaseManager.printLog("1匹配  " + pojo.X1);

                        break;
                    case 2:
                        pojo.X0 = matcher.group(0);
                        ReleaseManager.printLog("0匹配    " + pojo.X0);
                        pojo.X1 = matcher.group(1);
                        ReleaseManager.printLog("1匹配    " + pojo.X1);
                        pojo.X2 = matcher.group(2);
                        ReleaseManager.printLog("2匹配    " + pojo.X2);
                        break;
                    case 3:
                        pojo.X0 = matcher.group(0);
                        ReleaseManager.printLog("0匹配    " + pojo.X0);
                        pojo.X1 = matcher.group(1);
                        ReleaseManager.printLog("1匹配    " + pojo.X1);
                        pojo.X2 = matcher.group(2);
                        ReleaseManager.printLog("2匹配    " + pojo.X2);
                        pojo.X3 = matcher.group(3);
                        ReleaseManager.printLog("3匹配    " + pojo.X3);
                        break;
                    default:
                        break;
                }

            }
        } else {
            ReleaseManager.printLog("正则匹配失败！！！！！！！！！！！！！");
        }
        return pojo;
    }


}
